<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>图片转换</title>
	</head>
	<body>
		<div id="">
			<img src="../img/1.jpg" id="img_id">
		</div>
		<br>
		<button type="button" onclick="begin();">开始</button>
		<!-- <button type="button" onclick="stop();">暂停</button> -->
	</body>
	<script type="text/javascript">
		function begin(){
			//定义一个数组装图片
			var arr = ["../img/2.jpg","../img/3.jpg","../img/4.jpg","../img/5.jpg","../img/6.jpg","../img/7.jpg","../img/8.jpg","../img/9.jpg"]
			
			var index = 0;
			setInterval(function(){
				if (index == arr.length) {
					index = 0;
					
				}
				document.getElementById("img_id").setAttribute("src",arr[index]);
				console.log(index)
				index++;
			},300)
		}
		// function stop(){
			
		// }
	</script>
</html>
